package com.starlink.common.log.configuration;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.util.Objects;

/**
 * @author: lichao
 * @date: 2021-06-21 17:55:53
 */
@Data
public class WebhookConfiguration implements InitializingBean {
    /**
     * 是否启动异常接口飞书机器人消息发送,默认不启用
     */
    private Boolean enabled=false;

    /**
     * 异常接口飞书机器人消息发送地址
     */
    private String url;

    /**
     * 异常接口飞书机器人消息密钥
     */
    private String secretKey;

    @Override
    public void afterPropertiesSet()  {
        if(this.enabled){
            Objects.requireNonNull(url,"starlink.webhook.url不能为空");
            Objects.requireNonNull(secretKey,"starlink.webhook.secretKey不能为空");
        }
    }
}
